#include "serialportlistenthread.h"
#include <QDebug>
#include <QSerialPortInfo>

using namespace std;




void SerialPortListenThread::run()
{
    QStringList portlist;

    int available = 0;

    while (1) {
        if (available == QSerialPortInfo::availablePorts().size()) {
            QThread::sleep(1);
            continue;
        }

        qDebug() << "SerialPortListenThread::run";
        portlist.clear();
        available = QSerialPortInfo::availablePorts().size();
        foreach (const QSerialPortInfo &serialPortInfo,
                QSerialPortInfo::availablePorts()) {
            portlist.push_back(serialPortInfo.portName());
        }

        emit Refresh(portlist);
        QThread::sleep(1);
    }
}
